define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'ques_merchant/index' + location.search,
                    add_url: 'ques_merchant/add',
                    edit_url: 'ques_merchant/edit',
                    del_url: 'ques_merchant/del',
                    multi_url: 'ques_merchant/multi',
                    table: 'ques_merchant',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                showExport: false,
                showToggle: false,
                showColumns: false,
                commonSearch: true,
                searchFormVisible: true,
                escape: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: '', title: __('序号'),operate:false,table:table,formatter: Table.api.formatter.natureorder},
                        // {field: 'openid', title: __('Openid')},
                        {field: 'nickname', title: __('Nickname'),operate:false},
                        {field: 'tel', title: __('Tel'),operate:false},
                        {field: 'a_1_text', title: __('A_1'),operate:false},
                        {field: 'a_1_1_text', title: __('A_1_1'),operate:false},
                        {field: 'a_2_text', title: __('A_2'),operate:false},
                        {field: 'a_2_1_text', title: __('接触病例时间'),operate:false},
                        {field: 'a_3_text', title: __('A_3'),operate:false},
                        {field: 'a_3_1_text', title: __('医学观察时间'),operate:false},
                        {field: 'a_3_2_text', title: __('A_3_2'),operate:false},
                        {field: 'a_4_text', title: __('A_4'),operate:false},
                        {field: 'a_4_1', title: __('身体状况说明'),operate:false},
                        {field: 'a_5_text', title: __('A_5'),operate:false},
                        {field: 'a_5_1_text', title: __('家庭成员接触病例时间'),operate:false},
                        {field: 'province', title: __('Province')},
                        // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'province_code', title: __('Province_code'),operate:false},
                        {field: 'city', title: __('City')},
                        // {field: 'city_code', title: __('City_code'),operate:false},
                        {field: 'district', title: __('District'),operate:false},
                        // {field: 'district_code', title: __('District_code'),operate:false},
                        {field: 'wx_formatted_address', title: __('Wx_formatted_address'),operate:false},
                        // {field: 'wx_province', title: __('Wx_province')},
                        // {field: 'wx_city', title: __('Wx_city')},
                        // {field: 'wx_district', title: __('Wx_district')},
                        {field: 'create_time', title: __('上报日期'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datestr},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});